package com.openbravo.pos.inventory.model;

import cn.ekuma.data.ui.swing.AbstractDTOTableModel;

import com.openbravo.bean.ProductPrefPrice;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppLocal;

public class ProductPrefPriceTableModel extends AbstractDTOTableModel<ProductPrefPrice>{
    public String[] getColumnNames() {
        return new String[] {
          AppLocal.getIntString("label.createTime"),
          AppLocal.getIntString("label.stockproduct"),
          AppLocal.getIntString("label.attributes"),
          AppLocal.getIntString("label.prodpricebuy"),
          //AppLocal.getIntString("label.baseProdpricebuy"),
          AppLocal.getIntString("label.preftype"),
          AppLocal.getIntString("label.storeNum"),
          AppLocal.getIntString("label.minNum"),
          AppLocal.getIntString("label.m_dStartDate"),
          AppLocal.getIntString("label.m_dStopDate"),
          AppLocal.getIntString("label.selledNum"),
          AppLocal.getIntString("label.customer"),
          AppLocal.getIntString("label.prefModeType"),
          AppLocal.getIntString("label.prefPrice"),
          AppLocal.getIntString("label.prefRate"),
          AppLocal.getIntString("label.LargessNum"),
          //AppLocal.getIntString("label.baseCustomerPrice"),
          //AppLocal.getIntString("label.basePrice"),
          AppLocal.getIntString("label.stockproduct"),//赠送商品
          AppLocal.getIntString("label.attributes")//赠送商品属性
        };
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
    	ProductPrefPrice p=getObj(rowIndex);
         switch(columnIndex){
         case 0:
        	 return Formats.TIMESTAMP.formatValue(p.getCurDate());
         case 1:
        	 return p.getP_name();
         case 2:
        	 return p.getAttributesetid();
         case 3:
        	 return Formats.CURRENCY.formatValue(p.getPrefBuyPrice());
         case 4:
        	 return getPrefTypeLocalName(p.getPrefType());
         case 5:
        	 return p.getStoreNum();
         case 6:
        	 return p.getMinNum();
         case 7:
        	 return Formats.TIMESTAMP.formatValue(p.getM_dStartDate());
         case 8:
        	 return Formats.TIMESTAMP.formatValue(p.getM_dStopDate());
         case 9:
        	 return p.getSelledNum();
         case 10:
        	 return p.isCustomerPref();
         case 11:
        	 return getPrefModeTypeLocalName(p.getPrefModeType());
         case 12:
        	 return Formats.CURRENCY.formatValue(p.getPrefPrice());
         case 13:
        	 return Formats.PERCENT.formatValue(p.getPrefRate());
         case 14:
        	 return p.getLargessNum();
         case 15:
        	 return p.getM_sLargessId();
         case 16:
        	 return p.getLargessAttributesetid();
         }
         return null;
    }
    
    public static String getPrefTypeLocalName(String prefType){
    	if(ProductPrefPrice.PREFTYPE_QuotaPref==prefType)
    		return  AppLocal.getIntString("list.preftype_quotapref");
    	else if(ProductPrefPrice.PREFTYPE_OverPref==prefType)
    		return  AppLocal.getIntString("list.preftype_overpref");
    	else if(ProductPrefPrice.PREFTYPE_TimeAndQuotaPref==prefType)
    		return  AppLocal.getIntString("list.preftype_timeandquotapref");
    	else if(ProductPrefPrice.PREFTYPE_TimeAndOverPref==prefType)
    		return  AppLocal.getIntString("list.preftype_timeandoverpref");
    	else if(ProductPrefPrice.PREFTYPE_TimePref==prefType)
    		return  AppLocal.getIntString("list.preftype_timepref");
    	return null;
    		
    }
    
    public static String getPrefModeTypeLocalName(String prefModeType){
    	if(ProductPrefPrice.PREFMODETYPE_SellPrice==prefModeType)
    		return  AppLocal.getIntString("list.prefmodetype_sellprice");
    	else if(ProductPrefPrice.PREFMODETYPE_Rate==prefModeType)
    		return  AppLocal.getIntString("list.prefmodetype_rate");
    	else if(ProductPrefPrice.PREFMODETYPE_Largess==prefModeType)
    		return  AppLocal.getIntString("list.prefmodetype_largess");
    	else if(ProductPrefPrice.PREFMODETYPE_SellPrice==prefModeType)
    		return  AppLocal.getIntString("list.prefmodetype_immelargess");
    	return null;
    }
}
